Skip to content

feat(api): support stored request details for analyses - #154

Merged
vvatelot merged 9 commits into
mainfrom
feat/api-mysql-postgres-db-engine
Aug 17, 2026
Merged

feat(api): support stored request details for analyses#154
vvatelot merged 9 commits into
mainfrom
feat/api-mysql-postgres-db-engine

Conversation

@vvatelot

@vvatelot vvatelot commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

  • add optional request-detail persistence for Ecoindex analysis tasks, including a new request-details table and a /{version}/ecoindexes/{id}/requests endpoint that aggregates stored items by category and domain
  • extend the scraper and worker flow to capture request domains, strip query parameters before persistence, and accept request details in batch imports
  • include recent branch work to support MySQL/PostgreSQL selection and make local/docker migration startup more reliable

Test plan

  • Run PYTHONPATH=bases:components uv run pytest test/components/ecoindex/models/test_scraper.py test/components/ecoindex/database/test_repository_queries.py test/components/ecoindex/scraper/test_scraper.py test/bases/ecoindex/backend/test_tasks.py -q
  • Run alembic upgrade head in a local API environment
  • Start the dockerized API stack and verify backend startup applies migrations automatically
  • Create an analysis with include_requests_detail=true and verify GET /v1/ecoindexes/{id}/requests

Made with Cursor

vvatelot and others added 7 commits July 15, 2026 11:58
Developers can now pick sqlite, mysql, or postgres at startup through a single DB_ENGINE setting, with Docker Compose profiles and local dev containers aligned on the same configuration.

Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(api): support emoji and punycode domains in analysis tasks

WebPage validation stores URLs as Unicode, which breaks requests for emoji
domains like xn--3s8h30f.ws. Use AnyHttpUrl for punycode conversion and pass
the encoded URL to the worker queue.

Fixes cnumr/EcoIndex#416

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(api): include request error details when URL pre-check fails

Expose SSL, timeout, and DNS errors in the unreachable URL response instead of empty parentheses.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Use an empty default and resolve it in the model validator so type checkers accept Settings().DATABASE_URL where a str is required.

Co-authored-by: Cursor <cursoragent@cursor.com>
Alembic needs projects/ecoindex_api as the working directory so it can find alembic.ini and load the local .env during init-dev-project.

Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure mysql/postgres containers are up before migration-upgrade and document which DB_HOST to use for local dev versus Docker Compose.

Co-authored-by: Cursor <cursoragent@cursor.com>
Store per-request resource details behind an opt-in task flag so analyses can expose aggregated request breakdowns by category and domain without persisting query parameters.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vvatelot vvatelot self-assigned this Aug 17, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation API Scraper tests components labels Aug 17, 2026
Duplicate test definitions introduced during merge caused ruff F811 failures in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

Coverage PR 154

Branch coverage •
FileStmtsMissCoverMissing
bases/ecoindex/backend/routers
   __init__.py140100% 
   bff.py27967%43, 50–51, 53, 79, 110, 117–118, 123
   ecoindex.py482058%76, 89, 97, 99, 120, 124–125, 129, 149, 153–154, 159, 162–163, 165, 190–191, 196–197, 203
   tasks.py885439%50–51, 56–58, 103–104, 108–109, 112, 116, 121–122, 125, 127–128, 133–135, 140, 147, 157, 174–177, 182–184, 186, 193–194, 196, 198–199, 201–202, 204, 206, 218–221, 251, 258, 276–279, 284, 286, 291–292, 294
bases/ecoindex/worker
   tasks.py704339%36–39, 49, 60, 71–75, 84, 86, 96–97, 106–107, 109, 116, 118–119, 130–132, 146–147, 161, 168, 179–180, 191–192, 205, 212, 218–220, 222–223, 231, 233–234, 239
components/ecoindex/database
   engine.py16569%21–22, 26, 31–32
components/ecoindex/database/models
   __init__.py410100% 
components/ecoindex/database/repositories
   ecoindex.py522454%40, 50, 52, 65, 72–74, 76–80, 82, 84, 86, 92, 98, 100, 115, 119, 121, 125, 132, 134
   worker.py22386%67–69
components/ecoindex/models
   __init__.py70100% 
   scraper.py690100% 
components/ecoindex/scraper
   scrap.py1163669%64, 72, 75–76, 78, 90, 96–97, 100, 115–123, 126–130, 132, 134, 141–147, 150, 191–192, 194
TOTAL175754569% 

@vvatelot
vvatelot merged commit 7eaad4a into main Aug 17, 2026
12 checks passed
@vvatelot
vvatelot deleted the feat/api-mysql-postgres-db-engine branch August 17, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API components documentation Improvements or additions to documentation Scraper tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant